<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="container-div">
    <div class="col-sm-12 search-collapse">
        <form id="sign-form">
            <div class="select-list">
                <ul>
                    <li class="select-time">
                        <label>考勤同步 时间： </label>
                        <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="beginTime"/>
                        <span>-</span>
                        <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime"/>
                    </li>
                    <li>
                        <a class="btn btn-primary btn-rounded btn-sm" onclick="syncSign()"><i class="fa fa-search"></i>&nbsp;同步</a>
                        <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                class="fa fa-refresh"></i>&nbsp;重置</a>
                    </li>
                </ul>
            </div>
        </form>
    </div>
    <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
        <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="pm:signInfo:add">
            <i class="fa fa-plus"></i> 添加
        </a>
        <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="pm:signInfo:edit">
            <i class="fa fa-edit"></i> 修改
        </a>
        <a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()"
           shiro:hasPermission="pm:signInfo:remove">
            <i class="fa fa-remove"></i> 删除
        </a>
    </div>

    <div class="col-sm-12 select-table table-striped">
        <table id="bootstrap-table" data-mobile-responsive="true"></table>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var detailFlag = [[${@permission.hasPermi('pm:signInfo:detail')}]];
    var prefix = ctx + "pm/signInfo";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            detailUrl: prefix + "/detail/{id}",
            modalName: "项目考勤",
            search: false,
            showSearch: false,
            showColumns: false,
            showToggle: false,
            showExport: false,
            showRefresh: false,
            columns: [{
                checkbox: true
            },
            {
				field : 'signId', 
				title : '考勤主键',
				visible: false
			},
			{
				field : 'empId', 
				title : '证件号码' 
			},
			{
				field : 'empNm', 
				title : '姓名' 
			},
			{
				field : 'signDt', 
				title : '考勤日期',
	            formatter: function(value, row, index) {
	            	var rowStr = "";
	            	if(!!row.signDt)
	            		rowStr = '<span>'+row.signDt.substr(0,10)+'</span>';
	            	return rowStr;
	            }
			},
			{
				field : 'signStti', 
				title : '开始时间',
	            formatter: function(value, row, index) {
	            	var rowStr = "";
	            	if(!!row.signStti)
	            		rowStr = '<span>'+row.signStti.substr(11,5)+'</span>';
	            	return rowStr;
	            }
			},
			{
				field : 'signEdti', 
				title : '结束时间',
	            formatter: function(value, row, index) {
	            	var rowStr = "";
	            	if(!!row.signEdti)
	            		rowStr = '<span>'+row.signEdti.substr(11,5)+'</span>';
	            	return rowStr;
	            }
			},
			{
				field : 'proId', 
				title : '项目主键',
				visible: false
			},
			{
				field : 'proSn', 
				title : '项目编号',
				visible: false
			},
			{
				field : 'proName', 
				title : '项目名称' 
			},
			{
				field : 'compId', 
				title : '供应商主键',
				visible: false
			},
			{
				field : 'compSn', 
				title : '供应商编号',
				visible: false
			},
			{
				field : 'compNm', 
				title : '供应商名称' 
			},
	        {
	            title: '操作',
	            align: 'center',
	            formatter: function(value, row, index) {
	            	var actions = [];
	            	actions.push('<a class="btn btn-info btn-xs ' + detailFlag + '" href="#" onclick="$.operate.detail(\'' + row.signId + '\')"><i class="fa fa-search"></i>详细</a> ');
	            	return actions.join('');
	            }
	        }]
        };
        $.table.init(options);
    });

    //同步考勤信息
    function syncSign() {
        var startTime = $("#startTime").val();
        var endTime = $("#endTime").val();
        var url = prefix + "/syncSignInfo";
        $.ajax({
            type: "post",
            url: url,
            data: JSON.stringify({ "beginTime": startTime, "endTime": endTime }),
            contentType: "application/json;charset=UTF-8",
                success: function (data) {
                if (data.code === 0) {
                    alert(data.msg);
                    $.table.refresh();
                }
            }
        })
    }
</script>
</body>
</html>